//register.js

Page({
  data: {
    focus: false,
    inputValue: '',
    title:'',
    address:'',
    OL:''

  },
  //地图定位
 showmap:function(){
   var that=this
   wx.chooseLocation({
      success: function(res){
        console.log(res);
        that.setData({
          address:res.address,
          OL: res.longitude+":"+res.latitude,
        });
      },
      fail: function() {},
      complete: function() {
          wx.redirectTo({
        url: "../shop/shop?id={{title}}"
      })
    }
  })
},
showShop:function(){
    wx.navigateTo({
      url: "../shop/shop"
    })
},

formSubmit: function(e) {  
      var address = e.detail.value.address;   
      var OL = e.detail.value.OL;   
      var getadd = e.detail.value.getadd;   
       //wx.showModal({content:address+OL+getadd});
       wx.sendSocketMessage({
       data:address+OL+getadd,
     success: function(res){
       wx.showModal({content: '成功'+res});
     }
   })
      },
onLoad:function(){
    wx.connectSocket({
      url: "ws://localhost:8080/main/websck",
    })
    wx.onSocketOpen(function() {
      console.log('WebSocket连接已经打开!')
    wx.sendSocketMessage({
      data: 'HELLO,WORLD'+Math.random()*0XFFFFFF.toString()
    })
    });
   wx.onSocketMessage(function(data) {
     console.log(data);
   });   //监听是否关闭
   wx.onSocketClose(function() {
     console.log('WebSocket连接已经关闭!')
   });
  },    //手动关闭连接
  setclose:function(e){
    console.log('WebSocket连接正在关闭!')
    wx.closeSocket();
  }
//提交数据
// submit(e){

//     // var id =e.currentTarget.id;
//     // var app=getApp();
//     // app.requestDetailid=id;
//     // wx.showModal({content:id});
//     var id=e.target.dataset.address;
//      var app=getApp();
//        app.requestDetailid=id
//        wx.showModal({content:id});

//    wx.sendSocketMessage({
//      data: 'String12312',
//      success: function(res){
//        wx.showModal({content: '成功'+res});
//      },
//      fail: function() {
//        // fail
//      },
//      complete: function() {
//        // complete
//      }
//    })

// },

 ,     
  onLoad: function(options) {      
    var that=this;
    return this.setData({      
      title: options.title
    })  ,
    console.log(that.data.title)
  } 



})